home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / MediaMonkey 3.06 / MediaMonkey_3.0.6.1190.exe / {app} / Scripts / Stats.vbs < prev    next >
Text File  |  2008-08-28  |  67KB  |  1,348 lines

  1. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2. ' This file can be replaced  in one of the future versions,
  3. ' so please if you want to modify it, make  a copy, do your
  4. ' modifications  in that copy and  change Scripts.ini  file 
  5. ' appropriately. 
  6. ' If you do not do this, you will lose  all your changes in
  7. ' this script when you install a new version of MediaMonkey
  8. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  9.  
  10. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  11. ' MediaMonkey statistics script
  12. ' This script was adapted by TheRocket from the 
  13. ' MediaMonkey Web Extension (MMWBE) also made by myself.
  14. ' Coded in December 2004 - January 2005.
  15. ' Thanks to Rusty for his suggestions and letting me
  16. ' include this script into the next versions!
  17. ' It shows globaly the songs you have in your MediaMonkey,
  18. ' and what you listen often. It can be a great way to
  19. ' find what type of music a person likes.
  20. ' Send us new statistics ideas in the MediaMonkey Forum!
  21. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  22.  
  23. Option Explicit
  24.  
  25. Public booStyleOn
  26.  
  27. Const intTopCount = 10
  28. Const mmAnchorRight = 4
  29. Const mmAnchorBottom = 8
  30. Const mmAlignTop = 1
  31. Const mmAlignBottom = 2
  32. Const mmAlignClient = 5
  33. Const mmListDropdown = 2
  34. Const mmFormScreenCenter = 4
  35.  
  36. 'Set English - United States system locale.
  37. SetLocale("en-us")
  38.  
  39. Sub ShowStats()
  40. Dim UI
  41. Dim Form
  42. Dim Foot
  43. Dim Btn
  44. Dim Btn2
  45. Dim WB
  46. Dim doc
  47. Dim DlgWidth
  48.  
  49.   Set UI = SDB.UI
  50.  
  51.   DlgWidth = 500
  52.  
  53.   ' Create the window to be shown
  54.   Set Form = UI.NewForm
  55.   Form.Common.SetRect 50, 50, DlgWidth, 400
  56.   Form.Common.MinWidth = 200
  57.   Form.Common.MinHeight = 150
  58.   Form.FormPosition = mmFormScreenCenter
  59.   Form.Caption = SDB.Localize("MediaMonkey Music Library Statistics")
  60.   Form.StayOnTop = True
  61.  
  62.   ' Create a panel at the bottom of the window
  63.   Set Foot = UI.NewPanel(Form)
  64.   Foot.Common.Align = mmAlignBottom
  65.   Foot.Common.Height = 35
  66.  
  67.   ' Create a button that saves the report
  68.   Set Btn2 = UI.NewButton(Foot)
  69.   Btn2.Caption = SDB.Localize("&Save as...")
  70.   Btn2.Common.SetRect DlgWidth - 261, 5, 150, 25
  71.   'Btn2.Common.Hint = SDB.Localize("Save this report")
  72.   Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom
  73.   Btn2.UseScript = Script.ScriptPath
  74.   Btn2.OnClickFunc = "SaveAs"
  75.  
  76.   ' Create a button that closes the window
  77.   Set Btn = UI.NewButton(Foot)
  78.   Btn.Caption = SDB.Localize("&Close")
  79.   Btn.Common.SetRect DlgWidth - 106, 5, 85, 25
  80.   'Btn.Common.Hint = SDB.Localize("Close this report")
  81.   Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom
  82.   Btn.Cancel = True
  83.   Btn.UseScript = Script.ScriptPath
  84.   Btn.OnClickFunc = "OnClose"
  85.    
  86.   ' Create a web browser component
  87.   Set WB = UI.NewActiveX(Form, "Shell.Explorer")
  88.  
  89.   ' process background threads
  90.   SDB.ProcessMessages
  91.  
  92.   WB.Common.Align = mmAlignClient      ' Fill all client rectangle
  93.   WB.Common.ControlName = "WB"
  94.  
  95.   Form.SavePositionName = "StatisticsWindow"
  96.   Form.Common.Visible = True                ' Only show the form, don't wait for user input
  97.   SDB.Objects("Statistics") = Form  ' Save reference to the form somewhere, otherwise it would simply disappear
  98.   WB.SetHTMLDocument( BuildReport(false))
  99.  
  100.   ' process background threads
  101.   SDB.ProcessMessages
  102.  
  103. End Sub
  104.  
  105. Sub OnClose(Btn)
  106.   SDB.Objects("Statistics") = Nothing ' Remove the last reference to our form which also causes it to disappear
  107. End Sub
  108.  
  109. Function Style()
  110.   booStyleOn = Not booStyleOn
  111.   If booStyleOn Then
  112.     Style = ""
  113.   Else
  114.     Style = " class=""Dark"""
  115.   End If
  116. End Function
  117.  
  118. Public Function FormatFileSize(intFileLength)
  119. Dim strSize
  120.     strSize = SDB.Localize("Bytes")
  121.     If intFileLength >= 1024 Then
  122.       intFileLength = Round(intFileLength / 1024)
  123.       strSize = SDB.Localize("KB")
  124.     End If
  125.     If intFileLength >= 1024 Then
  126.       intFileLength = Round(intFileLength / 1024, 2)
  127.       strSize = SDB.Localize("MB")
  128.     End If
  129.     If intFileLength >= 1024 Then
  130.       intFileLength = Round(intFileLength / 1024, 2)
  131.       strSize = SDB.Localize("GB")
  132.     End If
  133.     If intFileLength >= 1024 Then
  134.       intFileLength = Round(intFileLength / 1024, 2)
  135.       strSize = SDB.Localize("TB")
  136.     End If
  137.     FormatFileSize = intFileLength & " " & strSize
  138. End Function
  139.  
  140. Public Function FormatTime(intLength)
  141.   Dim strLength, intLengthHeures, intLengthMinutes, intLengthSecondes, datLength
  142.   Dim strTimeSeparator
  143.   'Find out the current time separator (for some locales, it is a period)
  144.   datLength = TimeSerial(11, 11, 11)
  145.   strLength = FormatDateTime(datLength,vbshorttime)
  146.   strTimeSeparator = left(replace(strLength,"1",""),1)
  147.  
  148.   intLength = CCur(intLength / 1000)
  149.   intLengthHeures = Int((intLength / 60) / 60)
  150.   intLengthMinutes = Int((intLength / 60) Mod 60)
  151.   intLengthSecondes = Int(intLength Mod 60)
  152.  
  153.   strLength = intLengthHeures & strTimeSeparator
  154.   if intLengthMinutes < 10 then strLength = strLength & "0"
  155.   strLength = strLength & intLengthMinutes & strTimeSeparator
  156.  
  157.   if intLengthSecondes < 10 then strLength = strLength & "0"
  158.   strLength = strLength & intLengthSecondes
  159.  
  160.   FormatTime = strLength
  161. End Function
  162.  
  163.  ' escape XML string
  164. Function MapXML(srcstring)
  165.   srcstring = Replace(srcstring, "&", "&")
  166.   srcstring = Replace(srcstring, "<", "<")
  167.   srcstring = Replace(srcstring, ">", ">")
  168.   Dim i
  169.   i=1
  170.   While i<=Len(srcstring)
  171.     ' process background threads
  172.     SDB.ProcessMessages
  173.  
  174.     If (AscW(Mid(srcstring, i, 1))>127) Then
  175.       srcstring = Mid( srcstring, 1, i-1)+"&#"+CStr( AscW( Mid( srcstring, i, 1)))+";"+Mid( srcstring, i+1, Len(srcstring))
  176.     End If
  177.     i=i+1
  178.   WEnd
  179.   If srcstring="" Then
  180.     srcstring = " "
  181.   End IF
  182.   MapXML = srcstring
  183. End Function
  184.  
  185.  
  186. Function ExtractText(ByVal inText, ByVal inDebut, ByVal inFin)
  187.     Dim pos1
  188.     Dim pos2
  189.  
  190.     pos1 = InStr(1, inText, inDebut)
  191.     If pos1 = 0 Then pos1 = 1 Else pos1 = pos1 + Len(inDebut)
  192.     pos2 = InStr(pos1, inText, inFin)
  193.     If pos2 < pos1 Then pos2 = Len(inText) + 1
  194.     ExtractText = Mid(inText, pos1, pos2 - pos1)
  195.     
  196. End Function
  197.  
  198. Function ExtractTextInvert(ByVal inText, ByVal inDebut, ByVal inFin)
  199.     ExtractTextInvert = StrReverse(ExtractText(StrReverse(inText), StrReverse(inDebut), StrReverse(inFin)))
  200. End Function
  201.  
  202. function ExtractPathName(strPath)
  203.   dim StrTemp
  204.   StrTemp= ExtractTextInvert(strPath,"","\")
  205.   ExtractPathName = Left(strPath, Len(strPath) - Len(StrTemp))
  206. end function
  207.  
  208. Function ShowRating(intNo, booForExport)
  209. Dim a
  210.   If intNo = -1 Then
  211.     ShowRating = " "
  212.   ElseIf intNo = 0 Then
  213.     if not booForExport then
  214.       ShowRating = "<img src=""" & ExtractPathName(script.scriptpath) & "\bomb.png"" border=""0"" width=""10"" height=""11"">"
  215.     else
  216.       ShowRating = "0"
  217.     end if
  218.   Else
  219. '    ShowRating = round(intNo / 10) / 2
  220.     For a = 20 To (intNo + 4) Step 20
  221.       ' process background threads
  222.       SDB.ProcessMessages
  223.       if not booForExport then
  224.         ShowRating = ShowRating & "<img src=""" & ExtractPathName(script.scriptpath) & "\star.png"" width=""10"" height=""11"" border=""0"">"
  225.       else
  226.         ShowRating = ShowRating & "*"
  227.       end if
  228.     Next
  229.   End If
  230.   If ((intNo + 4)  Mod 20) >= 10 Then
  231.     if not booForExport then
  232.       ShowRating = ShowRating & "<img src=""" & ExtractPathName(script.scriptpath) & "\half-star.png"" width=""10"" height=""11"" border=""0"">"
  233.     else
  234.       ShowRating = ShowRating & """
  235.     end if
  236.   End If
  237. End Function
  238.  
  239. function NoNull(VarCanBeNull, varWhenNull)
  240.   if IsNull (VarCanBeNull) Then
  241.     NoNull = varWhenNull
  242.   else
  243.     if IsNumeric (VarCanBeNull) Then
  244.       NoNull = VarCanBeNull
  245.     else
  246.       if VarType (VarCanBeNull) = vbString Then
  247.         if Len (VarCanBeNull) > 0 Then
  248.           NoNull = VarCanBeNull
  249.         else
  250.           NoNull = varWhenNull
  251.         end if
  252.       else
  253.         NoNull = varWhenNull
  254.       end if
  255.     end if
  256.   end if
  257. end function
  258.  
  259. Sub SaveAS(Btn)
  260.   Dim strExportTo
  261.   Dim booSave
  262.   Dim fout 
  263.   Dim fso
  264.  
  265.   With SDB.CommonDialog
  266.     .DefaultExt = "html"
  267.     '.FileName = SDB.Localize("Save AS...")
  268.     .Filter = "HTML (*.htm)|*.htm|All files (*.*)|*.*"
  269.     .Title = SDB.Localize("Exporting...")
  270.     .InitDir = SDB.IniFile.StringValue("Scripts", "LastExportStatsDir")
  271.     .ShowSave
  272.     booSave = .Ok
  273.     strExportTo = .FileName
  274.   End With
  275.  
  276.   if booSave then
  277.     ' Connect to the FileSystemObject
  278.     Set fso = SDB.Tools.FileSystem
  279.  
  280.     ' Create the output file 
  281.     Set fout = fso.CreateTextFile(strExportTo, True) 
  282.  
  283.     ' Write header line 
  284.     fout.Write BuildReport(true) 
  285.     ' Close the output file and finish 
  286.     fout.Close 
  287.     
  288.     set fout = nothing
  289.     set fso = nothing
  290.  
  291.   end if
  292.  
  293. end sub
  294.  
  295. Function BuildReport(booForExport)
  296.   Dim qryStats 
  297.   Dim strSQL
  298.   Dim intArtistsCount
  299.   Dim intArtistsCountPlayed
  300.   Dim intAlbumCount
  301.   Dim intAlbumsCountPlayed
  302.   Dim intGenreCount
  303.   Dim intGenreCountPlayed
  304.   Dim intLength
  305.   Dim intFileLength
  306.   Dim intLengthPlayed
  307.   Dim intFileLengthPlayed
  308.   Dim intYearCount
  309.   Dim intYearCountPlayed
  310.   Dim intPlaylistCount
  311.   Dim intPlaylistCountPlayed
  312.   Dim intPlayed
  313.   Dim intAllCount
  314.  
  315.   Dim strOut
  316.  
  317.   strOut = ""
  318.     
  319.   'Building base page
  320.   strOut = strOut & "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbcrlf
  321.   strOut = strOut & "<html>" & vbcrlf
  322.   strOut = strOut & "  <head>" & vbcrlf
  323.   strOut = strOut & "    <title>" & SDB.Localize("MediaMonkey Music Library Statistics") & "</title>" & vbcrlf
  324.   strOut = strOut & "  </head>" & vbcrlf
  325.  
  326.   strOut = strOut & "<STYLE TYPE=text/css>" & vbcrlf
  327.   strOut = strOut & "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbcrlf
  328.   strOut = strOut & "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbcrlf
  329.   strOut = strOut & "P{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000;}" & vbcrlf
  330.   strOut = strOut & "TH{font-family:'Verdana',sans-serif; font-size:10pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbcrlf
  331.   strOut = strOut & "TD{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbcrlf
  332.   strOut = strOut & "TR.dark{background-color:#EEEEEE}" & vbcrlf
  333.   strOut = strOut & "TR.aleft TH{text-align:left}" & vbcrlf
  334.   strOut = strOut & "</STYLE>" & vbcrlf
  335.  
  336.   strOut = strOut & "  <body>" & vbcrlf
  337.   strOut = strOut & "    <H1>" & SDB.Localize("MediaMonkey Music Library Statistics") & "</H1>" & vbcrlf
  338.   
  339.   ' process background threads
  340.   SDB.ProcessMessages
  341.   
  342.   'Totals
  343.   strSQL = "SELECT Count(*) AS Nombre FROM Artists WHERE ID <> 0 AND Tracks>0"     ' Track artists only
  344.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  345.   intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  346.   
  347.   ' process background threads
  348.   SDB.ProcessMessages
  349.  
  350.   strSQL = "SELECT Count(Distinct Artists.ID) AS CountOfID FROM Artists WHERE Artists.ID IN ( SELECT ArtistsSongs.IDArtist FROM ArtistsSongs WHERE ArtistsSongs.IDSong IN ( SELECT Played.IDSong FROM Played))"
  351.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  352.   intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  353.   
  354.   ' process background threads
  355.   SDB.ProcessMessages
  356.  
  357.   strSQL = "SELECT Count(*) AS Nombre FROM Albums WHERE Album<>'' AND Album<>' '"
  358.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  359.   intAlbumCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  360.   
  361.   ' process background threads
  362.   SDB.ProcessMessages
  363.  
  364.   strSQL = "SELECT Count(Distinct Albums.ID) AS CountOfID FROM Albums WHERE Albums.ID IN ( SELECT Songs.IDAlbum FROM Songs WHERE Songs.ID IN (SELECT Played.IDSong FROM Played))"
  365.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  366.   intAlbumsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  367.   
  368.   ' process background threads
  369.   SDB.ProcessMessages
  370.  
  371.   strSQL = "SELECT Count(Genres.IDGenre) AS Nombre FROM Genres WHERE GenreName <> ''"
  372.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  373.   intGenreCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  374.   
  375.   ' process background threads
  376.   SDB.ProcessMessages
  377.  
  378.   strSQL = "SELECT Count(Distinct Genres.IDGenre) AS CountOfID FROM Genres WHERE Genres.IDGenre IN (SELECT GenresSongs.IDGenre FROM GenresSongs WHERE GenresSongs.IDSong IN (SELECT Played.IDSong FROM Played))"
  379.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  380.   intGenreCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  381.  
  382.   ' process background threads
  383.   SDB.ProcessMessages
  384.  
  385.   strSQL = "SELECT Count(Distinct CAST((Songs.Year/10000) AS INTEGER)) AS Nombre FROM Songs WHERE Songs.Year > 0"
  386.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  387.   intYearCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  388.  
  389.   ' process background threads
  390.   SDB.ProcessMessages
  391.  
  392.   strSQL = "SELECT Count(Distinct CAST((Songs.Year/10000) AS INTEGER)) AS CountOfID FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Year > 0"
  393.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  394.   intYearCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  395.  
  396.   ' process background threads
  397.   SDB.ProcessMessages
  398.  
  399.   strSQL = "SELECT Count(*) AS Nombre FROM PlayLists WHERE (ISAutoPlayList ISNULL or IsAutoPlaylist=0)"
  400.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  401.   intPlaylistCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  402.  
  403.   ' process background threads
  404.   SDB.ProcessMessages
  405.  
  406.   strSQL = "SELECT Count(Distinct PlayLists.IDPlaylist) AS CountOfID FROM "
  407.   strSQL = strSQL & " PlayLists WHERE PlayLists.IDPlaylist "
  408.   strSQL = strSQL & " IN (SELECT PlaylistSongs.IDPlaylist FROM PlaylistSongs WHERE PlaylistSongs.IDSong "
  409.   strSQL = strSQL & " IN (SELECT Played.IDSong FROM Played)) "
  410.   strSQL = strSQL & " AND (PlayLists.ISAutoPlayList ISNULL or Playlists.IsAutoPlaylist=0)"
  411.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  412.   intPlaylistCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  413.  
  414.   ' process background threads
  415.   SDB.ProcessMessages
  416.  
  417.   strSQL = "SELECT Count(Distinct Played.IDSong) AS Nombre FROM Played"
  418.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  419.   intPlayed = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  420.  
  421.   ' process background threads
  422.   SDB.ProcessMessages
  423.  
  424.   strSQL = "SELECT Count(*) AS Nombre, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Songs"
  425.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  426.   intAllCount = CLng(NoNull(qryStats.StringByName("Nombre"),0))
  427.   intLength = CCur(NoNull(qryStats.ValueByName("TotalLength"),0))
  428.   intFileLength = CCur(NoNull(qryStats.ValueByName("TotalFileLength"),0))
  429.  
  430.   ' process background threads
  431.   SDB.ProcessMessages
  432.  
  433.   strSQL = "SELECT Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Songs WHERE Songs.ID IN (SELECT Played.IdSong FROM Played)"
  434.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  435.   intLengthPlayed = CCur(NoNull(qryStats.ValueByName("TotalLength"),0))
  436.   intFileLengthPlayed = CCur(NoNull(qryStats.ValueByName("TotalFileLength"),0))
  437.  
  438.   ' process background threads
  439.   SDB.ProcessMessages
  440.  
  441.   strOut = strOut & "      <p/>" & vbcrlf
  442.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  443.   strOut = strOut & "          <tr><th colspan=""3"">" & SDB.Localize("Totals") & "</th></tr>" & vbcrlf
  444.   strOut = strOut & "          <tr class=""aleft""><th>" & SDB.Localize("Type") & "</th><th>" & SDB.Localize("Library") & "</th><th>" & SDB.Localize("Played") & "</th></tr>" & vbcrlf
  445.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Artists") & "</td><td>" & intArtistsCount & "</td><td>" & intArtistsCountPlayed & "</td></tr>" & vbcrlf
  446.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Albums") & "</td><td>" & intAlbumCount & "</td><td>" & intAlbumsCountPlayed & "</td></tr>" & vbcrlf
  447.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Genres") & "</td><td>" & intGenreCount & "</td><td>" & intGenreCountPlayed & "</td></tr>" & vbcrlf
  448.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Years") & "</td><td>" & intYearCount & "</td><td>" & intYearCountPlayed & "</td></tr>" & vbcrlf
  449.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Playlists") & "</td><td>" & intPlaylistCount & "</td><td>" & intPlaylistCountPlayed & "</td></tr>" & vbcrlf
  450.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks") & "</td><td>" & intAllCount & "</td><td>" & intPlayed & "</td></tr>" & vbcrlf
  451.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Length") & " (h:mm:ss)</td><td>" & FormatTime(intLength) & "</td><td>" & FormatTime(intLengthPlayed) & "</td></tr>" & vbcrlf
  452.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("File size") & "</td><td>" & FormatFileSize(intFileLength) & "</td><td>" & FormatFileSize(intFileLengthPlayed) & "</td></tr>" & vbcrlf
  453.   'strOut = strOut & "          <tr><td colspan=""3"">* = " & SDB.Localize("Parts of item played") & "</td></tr>" & vbcrlf
  454.   strOut = strOut & "        </table>" & vbcrlf
  455.   strOut = strOut & "      <p/>" & vbcrlf
  456.   
  457.   ' process background threads
  458.   SDB.ProcessMessages
  459.  
  460.   'Averages
  461.   Dim intAvgYear
  462.   Dim intAvgYearPlayed
  463.   Dim intAvgBitrate
  464.   Dim intAvgBitratePlayed
  465.   Dim intAvgRating
  466.   Dim intTracksPerAlbum
  467.   Dim intTracksPerAlbumPlayed
  468.   Dim intSongsPerGenre
  469.   Dim intSongsPerGenrePlayed
  470.   Dim intPlayPerDay
  471.   Dim intPlayedRating
  472.   Dim intSongsPerArtist
  473.   Dim intSongsPerArtistPlayed
  474.   Dim intSongsPerYear
  475.   Dim intSongsPerYearPlayed
  476.   'Dim intSongsPerRating
  477.   'Dim intSongsPerRatingPlayed
  478.  
  479.   strSQL = "SELECT Avg(Distinct CAST((Songs.Year/10000) AS INTEGER)) AS avgYear FROM Songs WHERE Songs.Year > 0"
  480.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  481.   intAvgYear = CCur(NoNull(qryStats.ValueByName("avgYear"),0))
  482.  
  483.   ' process background threads
  484.   SDB.ProcessMessages
  485.  
  486.   strSQL = "SELECT Avg(Distinct Cast((Songs.Year/10000) AS Integer)) AS avgYearPlayed FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Year > 0"
  487.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  488.   intAvgYearPlayed = CCur(NoNull(qryStats.ValueByName("avgYearPlayed"),0))
  489.  
  490.   ' process background threads
  491.   SDB.ProcessMessages
  492.  
  493.   strSQL = "SELECT Avg(SongLength) AS AvgLength, Avg(FileLength) AS AvgFileLength, Avg(Bitrate) AS AvgBitrate FROM Songs"
  494.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  495.   intLength = CCur(NoNull(qryStats.ValueByName("AvgLength"),0))
  496.   intFileLength = CCur(NoNull(qryStats.ValueByName("AvgFileLength"),0))
  497.   intAvgBitrate = CCur(NoNull(qryStats.ValueByName("AvgBitrate"),0))
  498.  
  499.   ' process background threads
  500.   SDB.ProcessMessages
  501.  
  502.   strSQL = "SELECT Avg(Songs.Bitrate) AS AvgBitratePlayed FROM Songs WHERE Songs.ID IN (SELECT Played.IDSong FROM Played)"
  503.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  504.   intAvgBitratePlayed = CCur(NoNull(qryStats.ValueByName("AvgBitratePlayed"),0))
  505.  
  506.   ' process background threads
  507.   SDB.ProcessMessages
  508.  
  509.   strSQL = "SELECT Avg(Songs.Rating) AS AvgRating FROM Songs WHERE Songs.Rating >= 0"
  510.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  511.   intAvgRating = CCur(NoNull(qryStats.ValueByName("AvgRating"),0))
  512.  
  513.   ' process background threads
  514.   SDB.ProcessMessages
  515.  
  516.   strSQL = "SELECT Avg(SongLength) AS AvgLength, Avg(FileLength) AS AvgFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong"
  517.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  518.   intLengthPlayed = CCur(NoNull(qryStats.ValueByName("AvgLength"),0))
  519.   intFileLengthPlayed = CCur(NoNull(qryStats.ValueByName("AvgFileLength"),0))
  520.   
  521.   ' process background threads
  522.   SDB.ProcessMessages
  523.  
  524.   strSQL = "SELECT Count( Songs.ID) AS CountOfID FROM Songs WHERE (Songs.Album <> '') AND (Songs.Album NOTNULL)"
  525.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  526.   if intAlbumCount > 0 then
  527.     intTracksPerAlbum = CCur(NoNull(qryStats.ValueByName("CountOfID"),0)) / intAlbumCount
  528.   else
  529.     intTracksPerAlbum = 0
  530.   End If
  531.   
  532.   ' process background threads
  533.   SDB.ProcessMessages
  534.  
  535.   strSQL = "SELECT Count( Songs.ID) AS CountOfID FROM Songs WHERE (Songs.Album <> '') AND (Songs.Album NOTNULL) AND Songs.IDAlbum IN "
  536.   strSQL = strSQL & "(SELECT Albums.ID FROM Albums WHERE Albums.ID IN ( SELECT Songs2.IDAlbum FROM Songs AS Songs2 WHERE Songs2.ID IN (SELECT Played.IDSong FROM Played)))"
  537.   
  538.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  539.   if intAlbumsCountPlayed > 0 then
  540.     intTracksPerAlbumPlayed = CCur(NoNull(qryStats.ValueByName("CountOfID"),0)) / intAlbumsCountPlayed
  541.   else  
  542.     intTracksPerAlbumPlayed = 0
  543.   end If
  544.  
  545.   ' process background threads
  546.   SDB.ProcessMessages
  547.  
  548.   strSQL = "SELECT Avg(CountOfID) AS AVGPlayed FROM (SELECT Count(Played.IdSong) AS CountOfID " 
  549.   strSQL = strSQL & "FROM Played  "
  550.   strSQL = strSQL & "GROUP BY Cast(Played.PlayDate AS Integer))"
  551.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  552.   intPlayPerDay = CCur(NoNull(qryStats.ValueByName("AVGPlayed"),0))
  553.  
  554.   ' process background threads
  555.   SDB.ProcessMessages
  556.  
  557.   strSQL = "SELECT Avg(Songs.Rating) AS AvgRatingPlayed FROM Songs WHERE Songs.Rating>0 AND PlayCounter>0"
  558.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  559.   intPlayedRating = CCur(NoNull(qryStats.ValueByName("AvgRatingPlayed"),0))
  560.  
  561.   ' process background threads
  562.   SDB.ProcessMessages
  563.  
  564.   strSQL = "SELECT Count( GenresSongs.ID) AS CountOfID FROM GenresSongs"
  565.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  566.   if intGenreCount > 0 then
  567.     intSongsPerGenre = CCur(NoNull(qryStats.ValueByName("CountOfID"),0)) / intGenreCount
  568.   else
  569.     intSongsPerGenre = 0
  570.   end If
  571.   
  572.   ' process background threads
  573.   SDB.ProcessMessages
  574.  
  575.   strSQL = "SELECT Count( GenresSongs.ID) AS CountOfID FROM GenresSongs WHERE GenresSongs.idGenre IN "
  576.   strSQL = strSQL & "       (SELECT GenresSongs2.IDGenre FROM GenresSongs AS GenresSongs2 WHERE GenresSongs2.IDSong IN "
  577.   strSQL = strSQL & "               (SELECT Played.IDSong FROM Played))"
  578.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  579.   if intGenreCountPlayed > 0 then
  580.     intSongsPerGenrePlayed = CCur(NoNull(qryStats.ValueByName("CountOfID"),0)) / intGenreCountPlayed
  581.   else  
  582.     intSongsPerGenrePlayed = 0
  583.   end If  
  584.  
  585.   ' process background threads
  586.   SDB.ProcessMessages
  587.  
  588.   strSQL = "SELECT Count( ArtistsSongs.ID) AS CountOfID FROM ArtistsSongs WHERE ArtistsSongs.PersonType = 1"
  589.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  590.   if intArtistsCount > 0 then
  591.     intSongsPerArtist = CCur(NoNull(qryStats.ValueByName("CountOfID"),0)) / intArtistsCount
  592.   else
  593.     intSongsPerArtist = 0
  594.   end If  
  595.  
  596.   ' process background threads
  597.   SDB.ProcessMessages
  598.  
  599.   strSQL = "SELECT Count( ArtistsSongs.ID) AS CountOfID FROM ArtistsSongs WHERE ArtistsSongs.PersonType = 1 AND ArtistsSongs.idArtist IN " 
  600.   strSQL = strSQL & "       (SELECT ArtistsSongs2.IDArtist FROM ArtistsSongs AS ArtistsSongs2 WHERE ArtistsSongs2.IDSong IN "
  601.   strSQL = strSQL & "               (SELECT Played.IDSong FROM Played))"
  602.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  603.   if intArtistsCountPlayed > 0 then
  604.     intSongsPerArtistPlayed = CCur(NoNull(qryStats.ValueByName("CountOfID"),0)) / intArtistsCountPlayed
  605.   else
  606.     intSongsPerArtistPlayed = 0
  607.   end If  
  608.  
  609.   ' process background threads
  610.   SDB.ProcessMessages
  611.  
  612.   strSQL = "SELECT Avg(CountOfID) AS AVGYear FROM ("
  613.   strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  614.   'strSQL = strSQL & "FROM Songs "
  615.   strSQL = strSQL & "FROM Songs WHERE Songs.Year <> -1 "
  616.   strSQL = strSQL & "GROUP BY Songs.Year)"
  617.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  618.   intSongsPerYear = CCur(NoNull(qryStats.ValueByName("AVGYear"),0))
  619.  
  620.   ' process background threads
  621.   SDB.ProcessMessages
  622.  
  623.   strSQL = "SELECT Avg(CountOfID) AS AVGYearPlayed FROM ("
  624.   strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  625.   strSQL = strSQL & "FROM Songs WHERE Songs.ID IN (SELECT Played.IDSong FROM Played) AND Songs.Year <> -1 "
  626.   strSQL = strSQL & "GROUP BY Songs.Year)"
  627.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  628.   intSongsPerYearPlayed = CCur(NoNull(qryStats.ValueByName("AVGYearPlayed"),0))
  629.  
  630.   'strSQL = "SELECT Avg(CountOfID) AS AVGTracksRating FROM ("
  631.   'strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  632.   'strSQL = strSQL & "FROM Songs WHERE Songs.Rating>0 "
  633.   'strSQL = strSQL & "GROUP BY Songs.Rating)"
  634.   'Set qryStats = SDB.Database.OpenSQL(strSQL)
  635.   'intSongsPerRating = CCur(NoNull(qryStats.ValueByName("AVGTracksRating"),0))
  636.  
  637.   'strSQL = "SELECT Avg(CountOfID) AS AVGTracksRatingPlayed FROM ("
  638.   'strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  639.   'strSQL = strSQL & "FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Rating>0 "
  640.   'strSQL = strSQL & "GROUP BY Songs.Rating)"
  641.   'Set qryStats = SDB.Database.OpenSQL(strSQL)
  642.   'intSongsPerRatingPlayed = CCur(NoNull(qryStats.ValueByName("AVGTracksRatingPlayed"),0))
  643.  
  644.   ' process background threads
  645.   SDB.ProcessMessages
  646.  
  647.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  648.   strOut = strOut & "          <tr><th colspan=""3"">" & SDB.Localize("Averages") & "</th></tr>" & vbcrlf
  649.   strOut = strOut & "          <tr class=""aleft""><th>" & SDB.Localize("Type") & "</th><th>" & SDB.Localize("Library") & "</th><th>" & SDB.Localize("Played") & "</th></tr>" & vbcrlf
  650.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Artist") & "</td><td>" & Round(intSongsPerArtist, 1) & "</td><td>" & Round(intSongsPerArtistPlayed, 1) & "</td></tr>" & vbcrlf
  651.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Album") & "</td><td>" & Round(intTracksPerAlbum, 1) & "</td><td>" & Round(intTracksPerAlbumPlayed, 1) & "</td></tr>" & vbcrlf
  652.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Genre") & "</td><td>" & Round(intSongsPerGenre, 1) & "</td><td>" & Round(intSongsPerGenrePlayed, 1) & "</td></tr>" & vbcrlf
  653.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Year") & "</td><td>" & Round(intSongsPerYear, 1) & "</td><td>" & Round(intSongsPerYearPlayed, 1) & "</td></tr>" & vbcrlf
  654.   'strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Rating") & "</td><td>" & Round(intSongsPerRating, 1) & "</td><td>" & Round(intSongsPerRatingPlayed, 1) & "</td></tr>" & vbcrlf
  655.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Bitrate (kbps)") & "</td><td>" & Round(intAvgBitrate/1000) & "</td><td>" & Round(intAvgBitratePlayed/1000) & "</td></tr>" & vbcrlf
  656.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Year") & "</td><td>" & Round(intAvgYear) & "</td><td>" & Round(intAvgYearPlayed) & "</td></tr>" & vbcrlf
  657.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks played per day") & "</td><td>-</td><td>" & Round(intPlayPerDay, 1) & "</td></tr>" & vbcrlf
  658.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Rating") & "</td><td>" & ShowRating(Round(intAvgRating),booForExport) & "</td><td>" & ShowRating(Round(intPlayedRating),booForExport) & "</td></tr>" & vbcrlf
  659.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Length") & " (h:mm:ss)</td><td>" & FormatTime(intLength) & "</td><td>" & FormatTime(intLengthPlayed) & "</td></tr>" & vbcrlf
  660.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("File size") & "</td><td>" & FormatFileSize(intFileLength) & "</td><td>" & FormatFileSize(intFileLengthPlayed) & "</td></tr>" & vbcrlf
  661.   strOut = strOut & "        </table>" & vbcrlf
  662.   strOut = strOut & "      <p/>" & vbcrlf
  663.  
  664.   ' process background threads
  665.   SDB.ProcessMessages
  666.  
  667.   'Top 10 Artists
  668.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  669.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Artists") & "</th></tr>" & vbcrlf
  670.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  671.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  672.   strOut = strOut & "            <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf
  673.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  674.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  675.   strOut = strOut & "          </tr>" & vbcrlf
  676.   
  677.   strSQL = "SELECT Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength, Artists.Artist FROM ArtistsSongs, Songs, Artists WHERE Songs.ID = ArtistsSongs.IDSong AND ArtistsSongs.IDArtist = Artists.ID GROUP BY ArtistsSongs.IDArtist ORDER BY Count(Songs.ID) DESC LIMIT " & intTopCount & "" 
  678.   
  679.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  680.   While Not qryStats.EOF
  681.  
  682.   ' process background threadsE
  683.   SDB.ProcessMessages
  684.  
  685.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  686.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  687.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & "</td>" & vbcrlf
  688.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  689.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  690.   strOut = strOut & "          </tr>" & vbcrlf
  691.     qryStats.Next
  692.   Wend
  693.   strOut = strOut & "        </table>" & vbcrlf
  694.   strOut = strOut & "      <p/>" & vbcrlf
  695.   
  696.   ' process background threads
  697.   SDB.ProcessMessages
  698.  
  699.   'Top 10 Artists Played
  700.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  701.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Artists played") & "</th></tr>" & vbcrlf
  702.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  703.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  704.   strOut = strOut & "            <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf
  705.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  706.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  707.   strOut = strOut & "          </tr>" & vbcrlf
  708.    
  709.   strSQL = "SELECT Sum(PlayCounter) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength, Artists.Artist "
  710.   strSQL = strSQL &  "FROM ArtistsSongs, Songs, Artists "
  711.   strSQL = strSQL &  "WHERE Songs.ID = ArtistsSongs.IDSong AND Songs.ID IN (SELECT Played.IDSong FROM Played) AND ArtistsSongs.IDArtist = Artists.ID "
  712.   strSQL = strSQL &  "GROUP BY ArtistsSongs.IDArtist "
  713.   strSQL = strSQL &  "ORDER BY Sum(PlayCounter) DESC LIMIT " & intTopCount & "" 
  714.  
  715.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  716.   While Not qryStats.EOF
  717.  
  718.   ' process background threads
  719.   SDB.ProcessMessages
  720.  
  721.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  722.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  723.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & "</td>" & vbcrlf
  724.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  725.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  726.   strOut = strOut & "          </tr>" & vbcrlf
  727.     qryStats.Next
  728.   Wend
  729.   strOut = strOut & "        </table>" & vbcrlf
  730.   strOut = strOut & "      <p/>" & vbcrlf
  731.  
  732.   'Top 10 Albums
  733.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  734.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top") & " " & intTopCount & " " & SDB.Localize("Albums") & "</th></tr>" & vbcrlf
  735.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  736.   strOut = strOut & "            <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf
  737.   strOut = strOut & "            <th>" & SDB.Localize("Album") & "</th>" & vbcrlf
  738.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  739.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  740.   strOut = strOut & "          </tr>" & vbcrlf
  741.   
  742.   strSQL = "SELECT Songs.AlbumArtist AS Artist, Albums.Album AS Album, Avg( Songs.Rating) AS Rating, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength "
  743.   strSQL = strSQL & "FROM Songs, Albums "
  744.   strSQL = strSQL & "WHERE Albums.ID <> 0 AND Albums.Album <> '' AND Albums.ID = Songs.IDAlbum "
  745.   strSQL = strSQL & "GROUP BY Songs.IDAlbum, Albums.Album "
  746.   strSQL = strSQL & "ORDER BY Rating Desc, TotalLength Desc Limit " & intTopCount & "" 
  747.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  748.   While Not qryStats.EOF
  749.   
  750. ' process background threads
  751.   SDB.ProcessMessages
  752.  
  753.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  754.   strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  755.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & " - " & MapXML(qryStats.StringByName("Album")) & "</td>" & vbcrlf
  756.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  757.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  758.   strOut = strOut & "          </tr>" & vbcrlf
  759.     qryStats.Next
  760.   Wend
  761.   strOut = strOut & "        </table>" & vbcrlf
  762.   strOut = strOut & "      <p/>" & vbcrlf
  763.  
  764.   'Top 10 Albums played
  765.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  766.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Albums played") & "</th></tr>" & vbcrlf
  767.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  768.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  769.   strOut = strOut & "            <th>" & SDB.Localize("Album") & "</th>" & vbcrlf
  770.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  771.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  772.   strOut = strOut & "          </tr>" & vbcrlf
  773.   
  774.   strSQL = "SELECT Songs.AlbumArtist AS Artist, Albums.Album AS Album, Sum( PlayCounter) AS CountOfID, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength "
  775.   strSQL = strSQL & "FROM Songs, Albums "
  776.   strSQL = strSQL & "WHERE Albums.ID <> 0 AND Albums.Album <> '' AND Albums.ID = Songs.IDAlbum AND "
  777.   strSQL = strSQL & "Songs.ID IN (SELECT Played.IDSong FROM Played) "
  778.   strSQL = strSQL & "GROUP BY Songs.IDAlbum, Albums.Album "
  779.   strSQL = strSQL & "ORDER BY Sum( PlayCounter) Desc Limit " & intTopCount & "" 
  780.   
  781.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  782.   While Not qryStats.EOF
  783.  
  784.   ' process background threads
  785.   SDB.ProcessMessages
  786.  
  787.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  788.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  789.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & " - " & MapXML(qryStats.StringByName("Album")) & "</td>" & vbcrlf
  790.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  791.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  792.   strOut = strOut & "          </tr>" & vbcrlf
  793.     qryStats.Next
  794.   Wend
  795.   strOut = strOut & "        </table>" & vbcrlf
  796.   strOut = strOut & "      <p/>" & vbcrlf
  797.   
  798.   ' process background threads
  799.   SDB.ProcessMessages
  800.  
  801.   'Top 10 Genres
  802.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  803.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Genres") & "</th></tr>" & vbcrlf
  804.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  805.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  806.   strOut = strOut & "            <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf
  807.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  808.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  809.   strOut = strOut & "          </tr>" & vbcrlf
  810.   
  811.   strSQL = "SELECT Count(Songs.ID) AS CountOfID, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength, Genres.GenreName FROM GenresSongs, Songs, Genres WHERE Songs.ID = GenresSongs.IDSong AND GenresSongs.IDGenre = Genres.IDGenre GROUP BY GenresSongs.IDGenre ORDER BY Count(Songs.ID) DESC LIMIT " & intTopCount & ""
  812.   
  813.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  814.   While Not qryStats.EOF
  815.  
  816.   ' process background threads
  817.   SDB.ProcessMessages
  818.  
  819.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  820.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  821.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("GenreName")) & "</td>" & vbcrlf
  822.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  823.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  824.   strOut = strOut & "          </tr>" & vbcrlf
  825.     qryStats.Next
  826.   Wend
  827.   strOut = strOut & "        </table>" & vbcrlf
  828.   strOut = strOut & "      <p/>" & vbcrlf
  829.   
  830.   ' process background threads
  831.   SDB.ProcessMessages
  832.  
  833.   'Top 10 genres played
  834.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  835.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Genres played") & "</th></tr>" & vbcrlf
  836.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  837.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  838.   strOut = strOut & "            <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf
  839.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  840.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  841.   strOut = strOut & "          </tr>" & vbcrlf
  842.   
  843.   strSQL = "SELECT Count(Songs.ID) AS CountOfID, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength, Genres.GenreName FROM GenresSongs, Songs, Genres WHERE Songs.ID = GenresSongs.IDSong AND Songs.ID IN (SELECT Played.IDSong FROM Played) AND GenresSongs.IDGenre = Genres.IDGenre GROUP BY GenresSongs.IDGenre ORDER BY Count(Songs.ID) DESC LIMIT " & intTopCount & ""
  844.   
  845.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  846.   While Not qryStats.EOF
  847.  
  848.   ' process background threads
  849.   SDB.ProcessMessages
  850.  
  851.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  852.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  853.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("GenreName")) & "</td>" & vbcrlf
  854.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  855.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  856.   strOut = strOut & "          </tr>" & vbcrlf
  857.     qryStats.Next
  858.   Wend
  859.   strOut = strOut & "        </table>" & vbcrlf
  860.   strOut = strOut & "      <p/>" & VbCrLf
  861.  
  862.   ' process background threads
  863.   SDB.ProcessMessages
  864.  
  865.   'ratings
  866.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  867.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Ratings") & "</th></tr>" & vbcrlf
  868.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  869.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  870.   strOut = strOut & "            <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf
  871.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  872.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  873.   strOut = strOut & "          </tr>" & vbcrlf
  874.  
  875.   '96 - 100 ratings
  876.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 96) AND (Songs.Rating <= 100)"
  877.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  878.  
  879.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  880.     While Not qryStats.EOF
  881.  
  882.       ' process background threads
  883.       SDB.ProcessMessages
  884.  
  885.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  886.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  887.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  888.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  889.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  890.       strOut = strOut & "          </tr>" & vbcrlf
  891.       qryStats.Next
  892.     Wend
  893.   End If
  894.  
  895.   '86 - 95 ratings
  896.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 86) AND (Songs.Rating <= 95)"
  897.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  898.  
  899.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  900.     While Not qryStats.EOF
  901.  
  902.       ' process background threads
  903.       SDB.ProcessMessages
  904.  
  905.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  906.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  907.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  908.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  909.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  910.       strOut = strOut & "          </tr>" & vbcrlf
  911.       qryStats.Next
  912.     Wend
  913.   End If
  914.  
  915.   '76 - 85 ratings
  916.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 76) AND (Songs.Rating <= 85)"
  917.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  918.  
  919.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  920.     While Not qryStats.EOF
  921.  
  922.       ' process background threads
  923.       SDB.ProcessMessages
  924.  
  925.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  926.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  927.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  928.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  929.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  930.       strOut = strOut & "          </tr>" & vbcrlf
  931.       qryStats.Next
  932.     Wend
  933.   End If
  934.  
  935.   '66 - 75 ratings
  936.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 66) AND (Songs.Rating <= 75)"
  937.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  938.  
  939.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  940.     While Not qryStats.EOF
  941.  
  942.       ' process background threads
  943.       SDB.ProcessMessages
  944.  
  945.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  946.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  947.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  948.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  949.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  950.       strOut = strOut & "          </tr>" & vbcrlf
  951.       qryStats.Next
  952.     Wend
  953.   End If
  954.  
  955.   '56 - 65 ratings
  956.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 56) AND (Songs.Rating <= 65)"
  957.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  958.  
  959.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  960.     While Not qryStats.EOF
  961.  
  962.       ' process background threads
  963.       SDB.ProcessMessages
  964.  
  965.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  966.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  967.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  968.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  969.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  970.       strOut = strOut & "          </tr>" & vbcrlf
  971.       qryStats.Next
  972.     Wend
  973.   End If
  974.  
  975.   '46 - 55 ratings
  976.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 46) AND (Songs.Rating <= 55)"
  977.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  978.  
  979.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  980.     While Not qryStats.EOF
  981.  
  982.       ' process background threads
  983.       SDB.ProcessMessages
  984.  
  985.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  986.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  987.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  988.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  989.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  990.       strOut = strOut & "          </tr>" & vbcrlf
  991.       qryStats.Next
  992.     Wend
  993.   End If
  994.  
  995.   '36 - 45 ratings
  996.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 36) AND (Songs.Rating <= 45)"
  997.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  998.  
  999.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1000.     While Not qryStats.EOF
  1001.  
  1002.       ' process background threads
  1003.       SDB.ProcessMessages
  1004.  
  1005.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1006.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1007.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1008.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1009.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1010.       strOut = strOut & "          </tr>" & vbcrlf
  1011.       qryStats.Next
  1012.     Wend
  1013.   End If
  1014.  
  1015.   '26 - 35 ratings
  1016.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 26) AND (Songs.Rating <= 35)"
  1017.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1018.  
  1019.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1020.     While Not qryStats.EOF
  1021.  
  1022.       ' process background threads
  1023.       SDB.ProcessMessages
  1024.  
  1025.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1026.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1027.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1028.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1029.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1030.       strOut = strOut & "          </tr>" & vbcrlf
  1031.       qryStats.Next
  1032.     Wend
  1033.   End If
  1034.  
  1035.   '16 - 25 ratings
  1036.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 16) AND (Songs.Rating <= 25)"
  1037.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1038.  
  1039.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1040.     While Not qryStats.EOF
  1041.  
  1042.       ' process background threads
  1043.       SDB.ProcessMessages
  1044.  
  1045.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1046.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1047.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1048.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1049.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1050.       strOut = strOut & "          </tr>" & vbcrlf
  1051.       qryStats.Next
  1052.     Wend
  1053.   End If
  1054.  
  1055.   '6 - 15 ratings
  1056.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 6) AND (Songs.Rating <= 15)"
  1057.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1058.  
  1059.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1060.     While Not qryStats.EOF
  1061.  
  1062.       ' process background threads
  1063.       SDB.ProcessMessages
  1064.  
  1065.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1066.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1067.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1068.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1069.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1070.       strOut = strOut & "          </tr>" & vbcrlf
  1071.       qryStats.Next
  1072.     Wend
  1073.   End If
  1074.  
  1075.   '0 ratings
  1076.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE Songs.Rating = 0"
  1077.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1078.  
  1079.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1080.     While Not qryStats.EOF
  1081.  
  1082.       ' process background threads
  1083.       SDB.ProcessMessages
  1084.  
  1085.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1086.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1087.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1088.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1089.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1090.       strOut = strOut & "          </tr>" & vbcrlf
  1091.       qryStats.Next
  1092.     Wend
  1093.   End If
  1094.  
  1095.   strOut = strOut & "        </table>" & vbcrlf
  1096.   strOut = strOut & "      <p/>" & vbcrlf
  1097.  
  1098.   'rating played
  1099.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  1100.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Ratings played") & "</th></tr>" & vbcrlf
  1101.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  1102.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  1103.   strOut = strOut & "            <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf
  1104.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  1105.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  1106.   strOut = strOut & "          </tr>" & vbcrlf
  1107.  
  1108.   '96 - 100 ratings played
  1109.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 96) AND (Songs.Rating <= 100) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"  
  1110.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1111.  
  1112.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1113.     While Not qryStats.EOF
  1114.  
  1115.       ' process background threads
  1116.       SDB.ProcessMessages
  1117.  
  1118.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1119.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1120.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1121.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1122.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1123.       strOut = strOut & "          </tr>" & vbcrlf
  1124.       qryStats.Next
  1125.     Wend
  1126.   End If
  1127.  
  1128.   '86 - 95 ratings played
  1129.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 86) AND (Songs.Rating <= 95) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1130.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1131.  
  1132.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1133.     While Not qryStats.EOF
  1134.  
  1135.       ' process background threads
  1136.       SDB.ProcessMessages
  1137.  
  1138.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1139.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1140.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1141.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1142.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1143.       strOut = strOut & "          </tr>" & vbcrlf
  1144.       qryStats.Next
  1145.     Wend
  1146.   End If
  1147.  
  1148.   '76 - 85 ratings played
  1149.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 76) AND (Songs.Rating <= 85) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1150.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1151.  
  1152.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1153.     While Not qryStats.EOF
  1154.  
  1155.       ' process background threads
  1156.       SDB.ProcessMessages
  1157.  
  1158.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1159.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1160.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1161.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1162.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1163.       strOut = strOut & "          </tr>" & vbcrlf
  1164.       qryStats.Next
  1165.     Wend
  1166.   End If
  1167.  
  1168.   '66 - 75 ratings played
  1169.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 66) AND (Songs.Rating <= 75) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1170.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1171.  
  1172.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1173.     While Not qryStats.EOF
  1174.  
  1175.       ' process background threads
  1176.       SDB.ProcessMessages
  1177.  
  1178.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1179.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1180.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1181.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1182.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1183.       strOut = strOut & "          </tr>" & vbcrlf
  1184.       qryStats.Next
  1185.     Wend
  1186.   End If
  1187.  
  1188.   '56 - 65 ratings played
  1189.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 56) AND (Songs.Rating <= 65) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1190.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1191.  
  1192.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1193.     While Not qryStats.EOF
  1194.  
  1195.       ' process background threads
  1196.       SDB.ProcessMessages
  1197.  
  1198.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1199.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1200.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1201.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1202.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1203.       strOut = strOut & "          </tr>" & vbcrlf
  1204.       qryStats.Next
  1205.     Wend
  1206.   End If
  1207.  
  1208.   '46 - 55 ratings played
  1209.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 46) AND (Songs.Rating <= 55) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1210.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1211.  
  1212.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1213.     While Not qryStats.EOF
  1214.  
  1215.       ' process background threads
  1216.       SDB.ProcessMessages
  1217.  
  1218.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1219.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1220.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1221.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1222.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1223.       strOut = strOut & "          </tr>" & vbcrlf
  1224.       qryStats.Next
  1225.     Wend
  1226.   End If
  1227.  
  1228.   '36 - 45 ratings played
  1229.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 36) AND (Songs.Rating <= 45) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1230.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1231.  
  1232.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1233.     While Not qryStats.EOF
  1234.  
  1235.       ' process background threads
  1236.       SDB.ProcessMessages
  1237.  
  1238.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1239.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1240.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1241.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1242.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1243.       strOut = strOut & "          </tr>" & vbcrlf
  1244.       qryStats.Next
  1245.     Wend
  1246.   End If
  1247.  
  1248.   '26 - 35 ratings played
  1249.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 26) AND (Songs.Rating <= 35) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1250.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1251.  
  1252.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1253.     While Not qryStats.EOF
  1254.  
  1255.       ' process background threads
  1256.       SDB.ProcessMessages
  1257.  
  1258.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1259.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1260.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1261.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1262.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1263.       strOut = strOut & "          </tr>" & vbcrlf
  1264.       qryStats.Next
  1265.     Wend
  1266.   End If
  1267.  
  1268.   '16 - 25 ratings played
  1269.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 16) AND (Songs.Rating <= 25) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1270.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1271.  
  1272.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1273.     While Not qryStats.EOF
  1274.  
  1275.       ' process background threads
  1276.       SDB.ProcessMessages
  1277.  
  1278.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1279.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1280.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1281.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1282.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1283.       strOut = strOut & "          </tr>" & vbcrlf
  1284.       qryStats.Next
  1285.     Wend
  1286.   End If
  1287.  
  1288.   '6 - 15 ratings played
  1289.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 6) AND (Songs.Rating <= 15) AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1290.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1291.  
  1292.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1293.     While Not qryStats.EOF
  1294.  
  1295.       ' process background threads
  1296.       SDB.ProcessMessages
  1297.  
  1298.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1299.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1300.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1301.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1302.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1303.       strOut = strOut & "          </tr>" & vbcrlf
  1304.       qryStats.Next
  1305.     Wend
  1306.   End If
  1307.  
  1308.   '0 ratings played
  1309.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE Songs.Rating = 0 AND Songs.ID IN (SELECT Played.IDSong FROM Played)"
  1310.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1311.  
  1312.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1313.     While Not qryStats.EOF
  1314.  
  1315.       ' process background threads
  1316.       SDB.ProcessMessages
  1317.  
  1318.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1319.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1320.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1321.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1322.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1323.       strOut = strOut & "          </tr>" & vbcrlf
  1324.       qryStats.Next
  1325.     Wend
  1326.   End If
  1327.  
  1328.   strOut = strOut & "        </table>" & vbcrlf
  1329.   strOut = strOut & "      <p/>" & vbcrlf
  1330.  
  1331.   strOut = strOut & "      <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  1332.   strOut = strOut & "        <tr><td style='border-bottom-width:0px'>" & vbcrlf
  1333.   strOut = strOut & "          " & SDB.Localize("Generated by ") & "<a href='http://www.mediamonkey.com'>MediaMonkey</a>" & SDB.Localize(" ON ") & MapXML(FormatDateTime(date(), vbLongDate)) & " " & SDB.Localize("at") & " " & MapXml(FormatDateTime(time(), vbLongTime))
  1334.   strOut = strOut & "        </td></tr>" & vbcrlf
  1335.   strOut = strOut & "      </table>" & vbcrlf
  1336.   strOut = strOut & "    <p/>" & vbcrlf
  1337.  
  1338.   strOut = strOut & "  </body>" & vbcrlf
  1339.   strOut = strOut & "</html>" & vbcrlf
  1340.  
  1341.  
  1342.   ' process background threads
  1343.   SDB.ProcessMessages
  1344.  
  1345.   BuildReport = strOut
  1346. End Function
  1347.  
  1348.